#include <iostream>
#include<vector>   

using namespace std;  //二维前缀和数组(前缀和矩阵)  O(n*m) + O(q)

int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    //读数据
    //注意：动态开辟二维数组的书写方式
    vector<vector<long long>> vv(n + 1, vector<long long>(m + 1));
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)   cin >> vv[i][j];

    //1.预处理一个前缀和矩阵 O(n*m)
    vector<vector<long long>> dp(n + 1, vector<long long>(m + 1));  //防止数据溢出
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)  
            dp[i][j] = dp[i][j - 1] + dp[i - 1][j] + vv[i][j] - dp[i - 1][j - 1];//O（1)

    //2.使用前缀和矩阵  O(q)
    int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
    while(q--)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        long long sum = dp[x2][y2] - dp[x2][y1 -1] - dp[x1 - 1][y2] + dp[x1 - 1][y1 - 1];   //O(1)
        cout << sum << endl;
    }

    return 0;
}